<template>
  <!--公司信息  -->
  <div style="height:520px">
    <FormPanel
      ref="infoCompany"
      :list="initForm"
      :cols="3"
      :formType="value.type"
      :labelWidth="140"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      formValue: {}
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //初始化数据
    init(data) {
      this.formValue = {};
      if (data.type === 'edit') {
        this.initForm.forEach(x => {
          x.initialValue = data.row[x.fieldName];
        });
      }
    },
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'INPUT',
          label: '公司名称',
          fieldName: 'field1',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '法定代表人',
          fieldName: 'field2',
          initialValue: ''
        },
        {
          type: 'DATE',
          label: '成立日期',
          fieldName: 'field3',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '2019-08-19',
          placeholder: '请选择',
          style: { width: '100%' }
        },{
          type: 'INPUT',
          label: '纳税人识别号',
          fieldName: 'field2',
          initialValue: ''
        },{
          type: 'INPUT',
          label: '有效期',
          fieldName: 'field2',
          initialValue: ''
        },
        {
          type: 'TEXT_AREA',
          label: '注册地址',
          fieldName: 'field12',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'TEXT_AREA',
          label: '登记机关',
          fieldName: 'field13',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'UPLOAD_IMG',
          label: '营业执照扫描件',
          fieldName: 'field14',
          upload: {
            actionUrl: '', //上传的地址
            fixedSize: [300, 500], //剪裁尺寸
            isCalcHeight: false,
            limit: 1 //上传数量
          },
          initialValue: '', 
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'UPLOAD_IMG',
          label: '法定代表人附件',
          fieldName: 'field15',
          upload: {
            actionUrl: '', //上传的地址
            fixedSize: [300, 500], //剪裁尺寸
            isCalcHeight: false,
            limit: 1 //上传数量
          },
          initialValue: '', 
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'UPLOAD_IMG',
          label: '首笔提车款附件',
          fieldName: 'field16',
          upload: {
            actionUrl: '', //上传的地址
            fixedSize: [300, 500], //剪裁尺寸
            isCalcHeight: false,
            limit: 1 //上传数量
          },
          initialValue: '', 
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        }
      ];
    },
    formChangeHandle(val) {
      this.formValue = val;
    }
  }
};
</script>